package org.nViron.nvMaps;

//~--- non-JDK imports --------------------------------------------------------

import org.nViron.nvCommon.nvPosition;
import org.nViron.nvSim.nvSimulator;

/**
 * Abstraction of a map source
 * @author Roland Haring <p>
 * <script type="text/javascript" src="http://www.ohloh.net/p/376434/widgets/project_basic_stats.js"></script>
 */
public abstract class nvMapSource {
    protected nvPosition  lr = new nvPosition();
    protected nvPosition  ul = new nvPosition();
    protected nvSimulator simulator;

    public nvMapSource(nvSimulator simulator) {
        this.simulator = simulator;
    }

    protected void forceUpdate() {
        ul.setLongitude(0);
        lr.setLongitude(0);
        ul.setLatitude(0);
        lr.setLatitude(0);
    }

    public nvSimulator getSimulator() {
        return simulator;
    }

    public abstract boolean init();

    public abstract void render();

    public void setAreaOfInterest(nvPosition ul, nvPosition lr) {
        float minDist = 1.0f;

        if ((this.ul.getDistance2d(ul) > minDist) || (this.lr.getDistance2d(lr) > minDist)) {
            this.lr = lr;
            this.ul = ul;
            updateAreaOfInterest();
        }
    }

    protected abstract void updateAreaOfInterest();
}



